 import {getTopCategoryAPI} from '@/apis/category'
 import {onBeforeRouteUpdate, useRoute} from 'vue-router'
export const useCategory=()=>{
    //  得到categoryData
const categoryData=ref({})
const router=useRoute()
const getCategory=async(id)=>{
    const res=await getTopCategoryAPI(id)
    categoryData.value=res.result
}
onMounted(()=>getCategory(router.params.id))
onBeforeRouteUpdate((to)=>{
  getCategory(to.params.id)
})
    return {
        categoryData
    }
}